home *** CD-ROM | disk | FTP | other *** search
/ ...taking it to the Macs! / ...taking it to the Macs!.iso / Extras / ActiveX Mac SDK / ActiveX SDK / Sample Controls / Menus / CPopupMenuControl.h < prev    next >
Encoding:
Text File  |  1996-12-20  |  2.4 KB  |  88 lines  |  [TEXT/CWIE]

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. //    CPopupMenuControl.h
  4. //
  5. //
  6.  
  7. #ifndef __CPOPUPMENUCONTROL__
  8. #define __CPOPUPMENUCONTROL__
  9.  
  10. #include "BDConsts.h"
  11. #include "BDInterfaces.h"
  12. #include "CBaseControl.h"
  13. #include "CBaseEventServer.h"
  14. #include "CBaseEventClient.h"
  15.  
  16. ///////////////////////////////////////////////////////////////////////////////
  17. //
  18. // Constants
  19. //
  20.  
  21. const short MAX_NUM_MENU_ITEMS             = 50;    // an arbitrary limit. We could make this dynamic. 
  22. const char MENUITEM_STR[]                 = "menuitem";
  23.  
  24. ///////////////////////////////////////////////////////////////////////////////
  25. //
  26. // class declaration
  27. //
  28.  
  29. class CPopupMenuControl : 
  30.     public CBaseControl,
  31.     public CBaseEventServer,
  32.     public CBaseEventClient,
  33.     public IDoMenuEvents
  34. {
  35. public:
  36.     
  37.     // *** CPopupMenuControl methods ***
  38.     CPopupMenuControl();
  39.     ~CPopupMenuControl();
  40.  
  41.     // *** IUnknown methods ***
  42.     STDMETHOD (QueryInterface)(REFIID refID, void** obj);
  43.     STDMETHOD_(ULONG,AddRef)(THIS) {CBaseControl::AddRef();}
  44.     STDMETHOD_(ULONG,Release)(THIS) {CBaseControl::Release();}
  45.  
  46.     // *** IObjectWithSite methods ***
  47.     STDMETHOD (SetSite)(THIS_ IUnknown* inUnkSite);
  48.     
  49.     // *** IControl methods ***
  50.     STDMETHOD (Draw) (THIS_ DrawContext* context);
  51.     STDMETHOD (DoIdle)(THIS_ Uint32 idleRefCon);
  52.  
  53.     // *** IPersistPropertyBag methods ***
  54.     STDMETHOD(Load)(IPropertyBag* propertyBag, IErrorLog* errorLog);
  55.     
  56.     // *** CBaseEventServer methods ***
  57.     STDMETHOD (FireOneEvent)(REFIID refID, long eventID, IUnknown* eventTarget, EventRecord* event);
  58.  
  59.     // **** IDoMenuEvents methods
  60.     STDMETHOD (Popup)(THIS_ IUnknown* source, PlatformEvent* event);
  61.     STDMETHOD (Clear)(THIS_ IUnknown* source, PlatformEvent* event);
  62.     STDMETHOD (RemoveItem)(THIS_ IUnknown* source, PlatformEvent* event, const CMenuItem & item);
  63.     STDMETHOD (AddItem)(THIS_ IUnknown* source, PlatformEvent* event, const CMenuItem & item);
  64.     
  65. protected:
  66.     static short GetMenuRSRCID(void);
  67.  
  68. protected:
  69.     void AddMenuItem(char * itemName);
  70.     void SetOriginatorName(char * theName);
  71.     
  72. protected:
  73.     char            mOriginatorName[Str255BufferLength];
  74.     MenuHandle        mMenuHandle;
  75.     CMenuItem        mItemSelected;
  76.     Str255             mMenuItemString[MAX_NUM_MENU_ITEMS];
  77.     Boolean            mIsIdling;    // True if we're getting idle messages
  78. #ifdef _DEBUG
  79.     char            mThisName[256];
  80. #endif
  81.  
  82. protected:
  83.     static short    gMenuRSRCID;
  84. };
  85.  
  86.  
  87. #endif // __CPOPUPMENUCONTROL__
  88.